﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Student1
{//------------------------------顺序存储结构------------------------
    struct Stud1
    {
        public int no;
        public string name;
        public double score;
    }
    class StudClass1
    {
        const int MaxSize = 100;
        Stud1[] st = new Stud1[MaxSize];
        int n;
        public void Create()
        {
            st[0].no = 2011001; st[0].name = "王华"; st[0].score = 90;
            st[1].no = 2011010; st[1].name = "刘丽"; st[1].score = 62;
            st[2].no = 2011006; st[2].name = "陈明"; st[2].score = 54;
            st[3].no = 2011009; st[3].name = "张强"; st[3].score = 95;
            st[4].no = 2011007; st[4].name = "许兵"; st[4].score = 76;
            st[5].no = 2011012; st[5].name = "李萍"; st[5].score = 88;
            st[6].no = 2011005; st[6].name = "李英"; st[6].score = 82;
            n = 7;
        }
        public string Display()
        {
            string mystr = "学号\t\t姓名\t\t分数\r\n";
            mystr += "============================================\r\n";
            int i;
            for (i = 0; i < n; i++)
            {
                mystr += st[i].no.ToString() + "\t\t" + st[i].name + "\t\t" +
                    st[i].score.ToString() + "\r\n";
            }
            return mystr;
        }
        public double Average()
        {
            int i;
            double sum = 0.0;
            for (i = 0; i < n; i++)
                sum += st[i].score;
            return (sum / n);
        }
        public double Rate()
        {
            int n1 = 0, i;
            for (i = 0; i < n1; i++)
                if (st[i].score >= 60.0) n1++;
            return (n1 * 1.0 / n);
        }
        public bool Findi(int i, ref string na, ref double sc)
        {
            if (i <= 0 || i > n)
                return false;
            else
            {
                na = st[i - 1].name;
                sc = st[i - 1].score;
                return true;
            }
        }

        public bool Findno(int no, ref string na, ref double sc)
        {
            int i = 0;
            while (i < n && st[i].no != no) i++;
            if (i < n)
            {
                na = st[i].name;
                sc = st[i].score;
                return true;
            }
            else return false;
        }
    }
    //------------------------------链式存储结构--------------------------------
    class Stud2
    {
        public int no;
        public string name;
        public double score;
        public Stud2 next;
    }
    class StudClass2
    {
        Stud2 head;
        public void Create()
        {
            Stud2 p1, p2, p3, p4, p5, p6, p7;
            p1 = new Stud2();
            p1.no = 2011001; p1.name = "王华"; p1.score = 90;
            p2 = new Stud2();
            p2.no = 2011010; p2.name = "刘丽"; p2.score = 62;
            p3 = new Stud2();
            p3.no = 2011006; p3.name = "陈明"; p3.score = 54;
            p4 = new Stud2();
            p4.no = 2011009; p4.name = "张强"; p4.score = 95;
            p5 = new Stud2();
            p5.no = 2011007; p5.name = "许兵"; p5.score = 76;
            p6 = new Stud2();
            p6.no = 2011012; p6.name = "李萍"; p6.score = 88;
            p7 = new Stud2();
            p7.no = 2011005; p7.name = "李英"; p7.score = 82;
            head = p1;
            p1.next = p2;
            p2.next = p3;
            p3.next = p4;
            p4.next = p5;
            p5.next = p6;
            p6.next = p7;
            p7.next = null;
        }
    }


}
